# Contributor: Nick Black <dankamongmen@gmail.com>
# Maintainer: Nick Black <dankamongmen@gmail.com>
pkgname=doctest
pkgver=2.4.0
pkgrel=0
pkgdesc="Fast header-only C++ unit testing"
url="https://github.com/onqtam/doctest"
arch="noarch"
license="MIT"
subpackages="$pkgname-dev"
makedepends="cmake"
source="$pkgname-$pkgver.tar.gz::https://github.com/onqtam/doctest/archive/$pkgver.tar.gz"

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake -B "$pkgname-$pkgver" \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_SHARED_LIBS=True \
		-DCMAKE_BUILD_TYPE=None \
		$CMAKE_CROSSOPTS
	cmake --build "$pkgname-$pkgver"
}

check() {
	CTEST_OUTPUT_ON_FAILURE=TRUE ctest --build-run-dir "$pkgname-$pkgver"
}

package() {
	DESTDIR="$pkgdir" cmake --build "$pkgname-$pkgver" --target install
}

sha512sums="96e8a7ceafbe99fbc09e3b5617c799cf0ff28102b24392ec14b55cd525e9dd156a996e578168009a494a7deb64f640d19b79137e5c067d103dba23d7c3375400  doctest-2.4.0.tar.gz"
